import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author 于金鹏
 * @Date 2024/12/11 15:56
 * @Package yujinpeng
 */
@WebServlet("/hwk")
public class TestHomework extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json;charset=utf-8");
        try {
            List<Student> students = ServletHomework.getData();
            resp.getWriter().write(JSONObject.toJSONString(students));
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }

    }
}
